<?php $this->load->view('templates/backend/header'); ?>
<h3><?php echo $this->lang->line('searchBooking');?></h3>
<?php 
    echo form_open('/auth/searchBooking/search',array('id'=>'ajaxform'));
        echo form_label($this->lang->line('customersName'), 'customersName');
        echo form_input(array('name' => 'customersName', 'id' => 'customersName', 'value' => '', 'placeholder' => 'Vui lòng nhập họ tên '.$this->lang->line('customersName')));
        echo form_error('customersName');
        
        echo form_label($this->lang->line('phone'), 'phone');
        echo form_input(array('name' => 'phone', 'id' => 'phone', 'value' => '', 'placeholder' => 'Vui lòng nhập '.$this->lang->line('phone').' '.$this->lang->line('customer')));//customer
        echo form_error('phone');
    
        echo form_label($this->lang->line('booking_place_code'), 'booking_place_code');
        echo form_input(array('name' => 'booking_place_code', 'id' => 'booking_place_code', 'value' => '', 'placeholder' => 'Vui lòng nhập '.$this->lang->line('booking_place_code')));
        echo form_error('booking_place_code');
        echo form_button(array('id' => 'submit', 'value' => 'Update', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-success')).' <span id="simple-msg-submit"></span>';
    echo form_close();
?>
<div id="content-msg"></div>

<script>
$("#ajaxform").on('submit',function(e)
{
    if($("#customersName").val() == "" && $("#phone").val() == "" && $("#booking_place_code").val() == ""){
        alert("Vui lòng nhập ít nhất 1 thông tin!");
        return false;
    }
    $("#simple-msg-submit").html("<img src='<?php echo base_url().'static/templates/frontend/home/images/';?>loading.gif'/>Vui lòng chờ....");
    var postData = $(this).serializeArray();
    var formURL = $(this).attr("action");
    setTimeout(function () {
        $.ajax(
            {
                url : formURL,
                type: "POST",
                data : {customersName:$("#customersName").val().trim(),phone:$("#phone").val().trim(),booking_place_code:$("#booking_place_code").val().trim()},
                cache: true,
                beforeSend: function(){
                    ///$('button[type="submit"]').attr('disabled','disabled');
                },
                success:function(data) 
                {
                    $("#content-msg").html(data);
                    $("#simple-msg-submit").html("<img src='<?php echo base_url().'static/templates/backend/images/icon/ok.png';?>'/>");
                },
                error: function() 
                {
                    $("#simple-msg-submit").html('F5 thử lại!!!!!!');
                }
            });
    }, 3000);
    e.preventDefault();	//STOP default action
});
</script>
<?php $this->load->view('templates/backend/footer'); ?>